package com.d3works.apps.bankpayment.service.bankorder;

import com.d3works.apps.bankpayment.db.BankOrder;
import com.d3works.apps.bankpayment.db.BankOrderFileFormat;
import com.d3works.apps.bankpayment.db.EbicsUser;
import com.d3works.apps.base.db.BankDetails;
import com.d3works.exception.D3worksException;
import com.d3works.meta.schema.actions.ActionView.ActionViewBuilder;
import com.google.inject.persist.Transactional;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import javax.xml.bind.JAXBException;
import javax.xml.datatype.DatatypeConfigurationException;

public interface BankOrderService {

  public BigDecimal computeBankOrderTotalAmount(BankOrder bankOrder) throws D3worksException;

  public BigDecimal computeCompanyCurrencyTotalAmount(BankOrder bankOrder) throws D3worksException;

  public void updateTotalAmounts(BankOrder bankOrder) throws D3worksException;

  @Transactional(rollbackOn = {Exception.class})
  public void confirm(BankOrder bankOrder)
      throws D3worksException, JAXBException, IOException, DatatypeConfigurationException;

  @Transactional(rollbackOn = {Exception.class})
  public void sign(BankOrder bankOrder);

  @Transactional(rollbackOn = {Exception.class})
  public void validate(BankOrder bankOrder)
      throws JAXBException, IOException, D3worksException, DatatypeConfigurationException;

  public void realize(BankOrder bankOrder) throws D3worksException;

  public File generateFile(BankOrder bankOrder)
      throws JAXBException, IOException, D3worksException, DatatypeConfigurationException;

  @Transactional(rollbackOn = {Exception.class})
  public BankOrder generateSequence(BankOrder bankOrder) throws D3worksException;

  public void setSequenceOnBankOrderLines(BankOrder bankOrder);

  public void checkLines(BankOrder bankOrder) throws D3worksException;

  @Transactional(rollbackOn = {Exception.class})
  public void validatePayment(BankOrder bankOrder) throws D3worksException;

  @Transactional(rollbackOn = {Exception.class})
  public BankOrder cancelPayment(BankOrder bankOrder) throws D3worksException;

  @Transactional(rollbackOn = {Exception.class})
  public void cancelBankOrder(BankOrder bankOrder) throws D3worksException;

  @Transactional
  public EbicsUser getDefaultEbicsUserFromBankDetails(BankDetails bankDetails);

  public String createDomainForBankDetails(BankOrder bankOrder);

  public BankDetails getDefaultBankDetails(BankOrder bankOrder);

  void checkMultiDate(BankOrder bankOrder) throws D3worksException;

  public void checkBankDetails(BankDetails bankDetails, BankOrder bankOrder)
      throws D3worksException;

  public boolean checkBankDetailsTypeCompatible(
      BankDetails bankDetails, BankOrderFileFormat bankOrderFileFormat);

  public boolean checkBankDetailsCurrencyCompatible(BankDetails bankDetails, BankOrder bankOrder);

  public void resetReceivers(BankOrder bankOrder);

  public ActionViewBuilder buildBankOrderLineView(
      String gridViewName, String formViewName, String viewDomain);

  public void setStatusToDraft(BankOrder bankOrder);

  public void setStatusToRejected(BankOrder bankOrder);
}
